package com.qianyu.api.controller.front;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qianyu.core.entity.base.PageDTO;
import com.qianyu.core.entity.base.Result;
import com.qianyu.core.entity.bean.QqRecycleOrder;
import com.qianyu.core.entity.dto.QqRecycleOrderDto;
import com.qianyu.core.service.QqRecycleOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "前台管理-回收订单", description = "wangzhicheng")
@RestController
@RequestMapping("/front/recycleOrder")
@RequiredArgsConstructor
public class QqRecycleOrderController {

    private final QqRecycleOrderService qqRecycleOrderService;

    /**
     * 新增回收单
     * @param dto
     * @return
     */
    @PostMapping("/saveQqRecycleOrder")
    @ApiOperation(value = "新增回收单")
    Result<String> saveQqRecycleOrder(@RequestBody  @Validated QqRecycleOrderDto.QqRecycleOrderSaveDto dto){
        qqRecycleOrderService.saveQqRecycleOrder(dto);
        return Result.success();
    }

    /**
     * 查询回收单
     */
    @PostMapping("/pageList")
    @ApiOperation(value = "代理商查询回收单")
    Result<Page<QqRecycleOrder>> pageList(PageDTO dto){
        return Result.success(qqRecycleOrderService.pageList(dto,1));
    }

    /**
     * 查询回收单
     */
    @PostMapping("/pageListByUser")
    @ApiOperation(value = "用户查询回收单")
    Result<Page<QqRecycleOrder>> pageListByUser(PageDTO dto){
        return Result.success(qqRecycleOrderService.pageList(dto,2));
    }

    /**
     * 审核回收单
     */
    @PostMapping("/checkByAgency")
    @ApiOperation(value = "代理商审核回收单")
    Result<String> checkRecycleOrder(@RequestBody @Validated QqRecycleOrderDto.QqRecycleOrderCheckDto dto){
        qqRecycleOrderService.checkRecycleOrder(dto);
        return Result.success();
    }
}
